<template>
  <a-card :bordered="false">
    <!-- 抽屉 -->
    <a-drawer
      :title="title"
      :width="screenWidth"
      @close="onClose"
      :visible="visible"
    >
      <!-- 抽屉内容的border -->
      <div
        :style="{
          padding:'10px',
          border: '1px solid #e9e9e9',
          background: '#fff',
        }">
        <div class="table-page-search-wrapper">
          <a-form layout="inline" @keyup.enter.native="searchQuery">

          </a-form>
        </div>


        <!-- 查询区域-END -->
                <div class="table-operator" style="margin-bottom: 5px;">
                  <a-button @click="handleAddGateWay" type="primary" icon="plus"> {{$t('base.add')}} </a-button>
                <!--  <a-button @click="handleAddLight" type="primary" icon="plus">新增路灯</a-button>-->
                </div>
        <!-- table区域-begin -->
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            :rowSelection="{fixed:true,selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"

            @change="handleTableChange">
            <template slot="avatarslot" slot-scope="text, record, index">
              <div class="anty-img-wrap">
                <img :src="getAvatarView(record)"/>
              </div>
            </template>
            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
              <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
              <a-button
                v-else
                :ghost="true"
                type="primary"
                icon="download"
                size="small"
                @click="uploadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
              <a-popconfirm :title="$t('base.confirmDelete')" @confirm="() => handleDelete(record.id)">
                    <a> <a-icon type="delete" /> {{$t('base.del')}} </a>
              </a-popconfirm>
            </span>

          </a-table>
        </div>
      </div>
    </a-drawer>
    <GlrPatternDeviceGateWayModel ref="glrPatternDeviceGateWayModel" @ok="modalFormOk"></GlrPatternDeviceGateWayModel>
    <GlrPatternDeviceLightModel ref="glrPatternDeviceLightModel" @ok="modalFormOk"></GlrPatternDeviceLightModel>
  </a-card>
</template>

<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { validateDuplicateValue,filterObj } from '@/utils/util'
  import GlrPatternDeviceGateWayModel from "./modules/GlrPatternDeviceGateWayModel";
  import GlrPatternDeviceLightModel from "./modules/GlrPatternDeviceLightModel";
  import {httpAction} from '@/api/manage'
  export default {
    name: "GlrPatternDeviceList",
    mixins:[JeecgListMixin],
    components: {
      GlrPatternDeviceLightModel,
      GlrPatternDeviceGateWayModel,
    },
    data () {
      return {
        title:this.$t('light.equipment') ,
        description: '网关绑定页面',
        visible: false,
        screenWidth: 800,
        patternId:"",
        disableMixinCreated:true,
        companyCode:'',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:this.$t('base.type') ,
            align:"center",
            dataIndex: 'type_dictText'
          },
          {
            title:this.$t('light.equipmentName'),
            align:"center",
            dataIndex: 'gateWayName'
          },
          {
            title: this.$t('base.operation'),
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "glr/glrPatternGateway/list",
          delete: "/glr/glrPatternGateway/delete",
          deleteBatch: "/glr/glrPatternGateway/deleteBatch",
          exportXlsUrl: "/glr/glrRadio/exportXls",
          importExcelUrl: "glr/glrRadio/importExcel",
          getProjectList: "/glr/glrProject/getProject",

        },
        dictOptions:{
        },
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
      },
      onClose() {
        this.visible = false;
        this.dataSource = [];
      },
      edit(record) {
        this.visible = true;
        this.queryParam.patternId = record.id;
        this.patternId=record.id;
        // 当其它模块调用该模块时,调用此方法加载字典数据
        this.loadData();
      },
      handleAddLight: function () {
        this.$refs.glrPatternDeviceLightModel.add(this.patternId);
      },
      handleAddGateWay(){
        this.$refs.glrPatternDeviceGateWayModel.add(this.patternId);
     }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>